package re;

import nfa.NFADesign;

/**
 * @author haoly
 * @title Pattern
 * @date 2025/4/17 08:36
 * @description 正则表达式模式抽象类
 */
public abstract class Pattern {

    public String bracket(int outerPrecedence){
        if (precedence() < outerPrecedence) {
            return "(" + this.toString() + ")";
        }else {
            return this.toString();
        }
    }

    public abstract int precedence();

    public abstract NFADesign toNFADesign();

    public Boolean matches(String s){
        return toNFADesign().accepts(s);
    }
}
